﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WISD.CarFriend.BLL.Web;

namespace WISD.CarFriend.Web.Admin.Module.RoleManage
{
    public partial class RoleAdd : Utility.BasicPage
    {
        private RoleManageModule m_RoleManageModuleBLL = new RoleManageModule();

        /// <summary>
        /// Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    // 验证权限
                    base.CheckPermission("RoleManage_Add");
                }
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }


        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int userType = Convert.ToInt32(rblUserType.SelectedValue);
                string userPermission = "";
                if (userType > 0)    //一般管理员
                {
                    userPermission = Request.Form["cbLevel"].Trim();
                }

                WISD.CarFriend.Model.CFModel.T_CF_UserRole userRoleModel
                    = new Model.CFModel.T_CF_UserRole();
                userRoleModel.UserRole = this.txtUserRole.Text.Trim();
                userRoleModel.UserPermission = userPermission;
                userRoleModel.Memo1 = userType.ToString();
                userRoleModel.Creator = Session["UserCode"].ToString();
                userRoleModel.CreateDate = DateTime.Now;
                userRoleModel.Reviser = Session["UserCode"].ToString();
                userRoleModel.ReviseDate = DateTime.Now;
                this.m_RoleManageModuleBLL.Add(userRoleModel);
                ShowMessageBox("新增成功！", "RoleList.aspx", "Success");
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }
    }
}